import { http } from '@/utils/axios/init'

/**
 * 合同
 */
// const contractPrefix = 'http://127.0.0.1:4523/m1/922025-0-default/Rest/projectContract'
const contractPrefix = '/ctms/Rest/projectContract'
// 列表查询
export function getProjectContractList(params) {
  return http.request({
    url: `${contractPrefix}/listByPage`,
    method: 'get',
    params
  })
}

// 提交
export function submitProjectContract(params) {
  return http.request(
    {
      url: `${contractPrefix}/submit`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 删除
export function delProjectContract(params) {
  return http.request(
    {
      url: `${contractPrefix}/delete`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 新增/修改(合同)
export function saveCustomizeForm(params) {
  return http.request({
    url: `${contractPrefix}/saveCustomizeForm`,
    method: 'post',
    params
  })
}

// 新增合同
export function addProjectContract(params) {
  return http.request({
    url: `${contractPrefix}/addContract`,
    method: 'post',
    params
  })
}

// 新增/修改（自定义表单内容）
export function addCustomizeForm(params) {
  return http.request(
    {
      url: `${contractPrefix}/addCustomizeForm`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}
// 暂存文件清单
export function saveFileList(params) {
  return http.request({
    url: `${contractPrefix}/saveFileList`,
    method: 'post',
    params
  })
}

// 获取表单列表
export function getformList(params) {
  return http.request({
    url: `/common/Rest/form/apply/list`,
    method: 'get',
    params
  })
}

// 获取总预算
export function getTotalBudget(params) {
  return http.request({
    url: `${contractPrefix}/getById`,
    method: 'get',
    params
  })
}

// 工作流（审批、撤回、退回、拒绝）
export function workflowOperateProcess(params) {
  return http.request({
    url: `${contractPrefix}/workflowOperateProcess`,
    method: 'post',
    params
  })
}

// 修改步骤号（合同)
export function updateContractRemark(params) {
  return http.request({
    url: `${contractPrefix}/updateRemark`,
    method: 'post',
    params
  })
}

/**
 * 付款计划
 */
const paymentPlanPrefix = '/ctms/Rest/projectContractPaymentPlan'

// 列表查询
export function getPaymentPlanList(params) {
  return http.request({
    url: `${paymentPlanPrefix}/list`,
    method: 'get',
    params
  })
}

// 新增（付款计划）
export function addPaymentPlan(params) {
  return http.request(
    {
      url: `${paymentPlanPrefix}/save`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 编辑
export function updatePaymentPlan(params) {
  return http.request(
    {
      url: `${paymentPlanPrefix}/update`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 删除
export function delPaymentPlan(params) {
  return http.request(
    {
      url: `${paymentPlanPrefix}/delete`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 详情
export function paymentPlanDetail(params) {
  return http.request({
    url: `${paymentPlanPrefix}/getById`,
    method: 'get',
    params
  })
}

/**
 * 预算费控
 */
const budgetControlPrefix = '/ctms/Rest/projectContractBudgetControl'

// 列表查询
export function getBudgetControlList(params) {
  return http.request({
    url: `${budgetControlPrefix}/list`,
    method: 'get',
    params
  })
}
// 列表查询 -树结构获取
export function getBudgetControlListTree(params) {
  return http.request({
    url: `${budgetControlPrefix}/treeList`,
    method: 'get',
    params
  })
}

// 新增（预算费控）
export function addBudgetControl(params) {
  return http.request(
    {
      url: `${budgetControlPrefix}/save`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 编辑
export function updateBudgetControl(params) {
  return http.request(
    {
      url: `${budgetControlPrefix}/update`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 删除
export function delBudgetControl(params) {
  return http.request(
    {
      url: `${budgetControlPrefix}/delete`,
      method: 'post',
      params
    },
    {
      successMessageText: '操作成功'
    }
  )
}

// 详情
export function budgetControlDetail(params) {
  return http.request({
    url: `${budgetControlPrefix}/getById`,
    method: 'get',
    params
  })
}

// 获取文件清单数据
export function getfileDetailList(params) {
  return http.request({
    url: `/ctms/Rest/projectFileListItem/commonDetailList`,
    method: 'get',
    params
  })
}

// 费用类型下拉选项获取
export function feeTypeSelectByContractType(params) {
  return http.request({
    url: `${budgetControlPrefix}/feeTypeSelectByContractType`,
    method: 'get',
    params
  })
}
/**
 * 预算费控
 */
const projectContractPaperPrefix = '/ctms/Rest/projectContractPaper'
// /Rest/projectContractPaper/saveCustomizeForm
// 新增/修改（纸质合同）
export function paperSaveCustomizeForm(params) {
  return http.request({
    url: `${projectContractPaperPrefix}/saveCustomizeForm`,
    method: 'post',
    params
  })
}

// 暂存文件清单（纸质合同）
export function paperSaveFileList(params) {
  return http.request({
    url: `${projectContractPaperPrefix}/saveFileList`,
    method: 'post',
    params
  })
}
// 提交（纸质合同）
export function paperSubmit(params) {
  return http.request({
    url: `${projectContractPaperPrefix}/submit`,
    method: 'post',
    params
  })
}

// 修改步骤号（纸质合同）
export function updateContractPaperRemark(params) {
  return http.request({
    url: `${projectContractPaperPrefix}/updateRemark`,
    method: 'post',
    params
  })
}
